package edu.mit.media.fv.aqview
{
	import edu.mit.media.fv.blocks.*;
	import edu.mit.media.fv.components.*;
	import edu.mit.media.fv.events.*;
	import edu.mit.media.fv.fluidspace.*;
	import edu.mit.media.fv.aqwidgets.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	
	public class AQPollResultViewer extends AQViewer
	{
		private var _question:AQPollQuestion;
		private var viewport:Sprite;
		private var graph:FVBarGraph;
		
		public function AQPollResultViewer()
		{
			super();
			
			this.graph = new FVBarGraph(10, 150, 650, 215);
			this.addChild(this.graph);
			
			FluidEventHandler.addEventListener(DisplayEvent.OPEN_POLL_RESULT, displayWidget);
		}
		public function displayWidget(event:DisplayEvent):void{
			FluidEventHandler.dispatchEvent(new WidgetEvent(WidgetEvent.DISPLAY_WIDGET, this, "Voice"));
			
			this.id = event.id;
			this._question.text = event.question;
			this.graph.setValues(event.results);
		}
		private function replyMessage(event:MouseEvent):void{
			var e:WidgetEvent = new WidgetEvent(WidgetEvent.DISPLAY_TEXT_BUILDER);
			e.subject = this._question.text;
			e.id = this.id;
			FluidEventHandler.dispatchEvent(e);
		}
		

	}
}